package com.company.nowcoder;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author jrue
 * @description https://www.nowcoder.com/practice/673454422d1b4a168aed31e449d87c00?tpId=98&tqId=32887&rp=1&ru=%2Fta%2F2019test&qru=%2Fta%2F2019test%2Fquestion-ranking&tPage=4
 * @date 2019/12/9 14:18
 * 给定一个无序的整型数组A[n],数组大小大于等于3,允许有值相同的元素;请设计算法找到该数组排序后第三大的元素值并输出.
 */
public class FindMaxKNum {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String[] split = s.substring(1, s.length() - 1).split(",");
        int[] nums = new int[split.length];

        for (int i = 0; i < split.length; i++) {
            nums[i] = Integer.parseInt(split[i]);
        }

        Arrays.sort(nums);
        System.out.println(nums[nums.length - 3]);

    }

}
